
#include "HowToPlayState.h"
#include "../../SGD Wrappers/CSGD_Direct3D.h"
#include "../../SGD Wrappers/CSGD_DirectInput.h"
#include "../../SGD Wrappers/CSGD_XAudio2.h"
#include "../../SGD Wrappers/CSGD_TextureManager.h"
#include "MainMenuState.h"
#include "Game.h"
#include "BitmapFont.h"
#include <cassert>
#include "tinyxml.h"


//Singleton accessor
HowToPlayState* HowToPlayState::GetInstance(void)
{
	static HowToPlayState instance;
	return &instance;
}


//Constructor
HowToPlayState::HowToPlayState(void)
{
}


//Destructor
HowToPlayState::~HowToPlayState(void)
{
}


//Enter
void HowToPlayState::Enter(void)
{
	//spaceshipImageID = CSGD_TextureManager::GetInstance()->LoadTexture( 
	//	_T("../resource/graphics/PlaceholderImage.png"),
	//	D3DCOLOR_XRGB(0, 0, 0)); 
	//
	//ufoImageID = CSGD_TextureManager::GetInstance()->LoadTexture( 
	//	_T("../resource/graphics/PlaceholderImage.png"),
	//	D3DCOLOR_XRGB(0, 0, 0) ); 
}


//Exit
void HowToPlayState::Exit(void)
{
	//CSGD_TextureManager::GetInstance()->UnloadTexture(spaceshipImageID);
	//CSGD_TextureManager::GetInstance()->UnloadTexture(ufoImageID);
}


//Input
bool HowToPlayState::Input(void)
{
	CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance();
	CSGD_XAudio2* XA = CSGD_XAudio2::GetInstance();

	//Ignore input when alt is down
	if (pDI->KeyDown(DIK_LALT) == true || pDI->KeyDown(DIK_RALT) == true)
		return true;

	if (pDI->KeyPressed(DIK_RETURN) || pDI->KeyPressed(DIK_ESCAPE) 
		|| pDI->MouseButtonPressed(0) || pDI->MouseButtonPressed(1))
	{
		Game::GetInstance()->ChangeState(MainMenuState::GetInstance());
		return true;
	}

	return true;
}


//Update
void HowToPlayState::Update(float dt)
{
}


//Render
void HowToPlayState::Render(void)
{
	CSGD_XAudio2* XA = CSGD_XAudio2::GetInstance();

	CBitmapFont* pFont = Game::GetInstance()->GetFont();
	pFont->Draw(_T("How to play"), 190, 170,1.0f, 
		D3DCOLOR_ARGB( 255, 255, 255, 255 ) );

	pFont->Draw( _T("Abcdefg"),
		290, 280, 0.8f, D3DCOLOR_ARGB(255, 255, 255, 255));

	pFont->Draw( _T("hijklmnop"),
		290, 330, 0.8f, D3DCOLOR_ARGB(255, 255, 255, 255));

	pFont->Draw( _T("qrstuvwxyz"),
		290, 380, 0.8f, D3DCOLOR_ARGB(255, 255, 255, 255));

	//RECT shiprect = {0,0,50,55};
	//CSGD_TextureManager::GetInstance()->Draw(spaceshipImageID, 350, 630, 
	//	1.0f, 1.0f, &shiprect);
	//
	//RECT red = {450,625,520,695};
	//CSGD_Direct3D::GetInstance()->DrawRect(red, D3DCOLOR_ARGB(120, 255, 50, 50));
	//
	//CSGD_TextureManager::GetInstance()->Draw(ufoImageID, 575, 635);
}
